//
//  HZPeiziAccountMoneyTableViewCell.m
//  Stock_Stategy
//
//  Created by MayerF on 2017/11/30.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "HZPeiziAccountMoneyTableViewCell.h"

@implementation HZAccountMoneyModel
@end

@interface HZPeiziAccountMoneyTableViewCell()
@property (nonatomic, strong)UILabel *pName;
@property (nonatomic, strong)UILabel *pText;
@end

@implementation HZPeiziAccountMoneyTableViewCell

+ (HZPeiziAccountMoneyTableViewCell *)cellTableView:(UITableView *)tableView
                                          indexPath:(NSIndexPath *)indexPath
                                          cellModel:(HZAccountMoneyModel *)cellModel
{
    static NSString *ID = @"peizi_accountCell";
    HZPeiziAccountMoneyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[HZPeiziAccountMoneyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        [cell p_commonInit];
        [cell p_initConstraints];
    }
    [cell p_updateDataWithmodel:cellModel indexPath:indexPath];
    
    return cell;
}

- (void)p_commonInit
{
    _pName = [UILabel new];
    _pText = [UILabel new];
    
    _pName.font = _pText.font = [UIFont systemFontOfSize:15];
    _pName.textColor = kGRAYColor;
}

- (void)p_initConstraints
{
    [self.contentView addSubview:_pName];
    [self.contentView addSubview:_pText];
    
    _pText.textAlignment = NSTextAlignmentRight;
    
    [_pName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(15);
        make.top.mas_equalTo(self).offset(5);
        make.bottom.mas_equalTo(self).offset(-5);
        make.right.mas_equalTo(_pText.mas_left);
    }];
    [_pText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_pName);
        make.right.mas_equalTo(self).offset(-15);
        make.width.mas_equalTo(_pName);
    }];
}

- (void)p_updateDataWithmodel:(HZAccountMoneyModel *)model indexPath:(NSIndexPath *)indexPath
{
    [self p_cleaOldData];
    [self p_updateNewData:model];
}
- (void)p_updateNewData:(HZAccountMoneyModel *)model
{
    _pName.text = model.mode_name;
    _pText.text = model.mode_text;
}
- (void)p_cleaOldData
{
    [_pName setText:@""];
    [_pText setText:@""];
}

@end
